package com.songjia.common.service.fallback;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.songjia.common.model.base.ResponseInfo;
import com.songjia.common.service.DeptClientService;

import feign.hystrix.FallbackFactory;

/**
 * 
 * 
 * @Description: DeptFeignClient熔断方法
 *
 * @author: songjia
 * @date: 2019年4月17日 下午9:57:20
 */
@Component // 不要忘记添加
public class DeptClientServiceFallbackFactory implements FallbackFactory<DeptClientService> {

	private static Logger logger = LoggerFactory.getLogger(DeptClientServiceFallbackFactory.class);

	@Override
	public DeptClientService create(Throwable cause) {
		return new DeptClientService() {

			@Override
			public ResponseInfo getAll() {
				logger.warn("DeptClientServiceFallbackFactory.getAll......熔断");
				return ResponseInfo.fail("获取全部部门列表异常");
			}

			@Override
			public ResponseInfo get(Long id) {
				logger.warn("DeptClientServiceFallbackFactory.get({})......熔断", id);
				return ResponseInfo.fail("根据部门ID获取部门详情异常");
			}
		};
	}

}
